#ifndef _EFFECT_MANANGER_H_
#define _EFFECT_MANANGER_H_

#include "Common.h"
#include "Resource.h"
#include "ResourceManager.h"
#include "Singleton.h"
#include "String.h"

class EffectPtr;

class  EffectManager: public ResourceManager,public Singleton<EffectManager>
{
public:
	EffectManager();
	~EffectManager();

	String	getEffectStringName(const uint32 & serial);
	
	ResourcePtr  create(const uint32 & serial,const NameValuePairList* params = 0);
	ResourceCreateOrRetrieveResult  \
		createOrRetrieve(const uint32 & serial,const NameValuePairList* params = 0);
	ResourcePtr  load(const uint32 & serial);
	ResourcePtr     reload(ResourceHandle handle);

	//user manager start
	void	Startup(const uint32 & gid,bool isBattle = true);
	void 	Shutdown(void);

	//用于得到一个Effect结构，用于向数据库追加新效果的记录
	Resource * newDumyEffect(void);
	void	freeDumyEffect(Resource * dumy);

	ResourcePtr  createEffectDatabase(Resource * dumy);
	//根据模板向数据库插入新的记录，返回插入的记录
	ResourcePtr	loadEffectDatabase(Resource * dumy);


	ResourcePtr   newDBObject(void);
	ResourcePtr   getDBObjectByHandle(const uint32 & handle);
	bool	getDBObjects(std::list<ResourcePtr> * objs,const uint32 & offset,const uint32 & limitcount,const char * query,...);




	//根据查询，返回符合条件的记录 offset 为翻页起点 limitcount 为取回角色最大数量 query 为查询条件在 WHERE之后
	bool	getEffectsList(std::list<EffectPtr> * effects,const uint32 & offset,const uint32 & limitcount,const char * query,...);

	//根据查询条件返回一个查询结果数量 query 为在WHERE之后的SQL语句
	uint32	getDBCount(const char * query,...);

	const bool & isBattleServer(void)	{	return m_battle_server;	}
protected:
	uint32		m_default_gid;
	String		m_default_group;
	bool		m_battle_server;
       /// @copydoc ResourceManager::createImpl
        Resource* createImpl(const String& name, ResourceHandle handle,
            const String& group, bool isManual, ManualResourceLoader* loader,
            const NameValuePairList* createParams);
};



#define   sEffectMgr   EffectManager::getSingleton()



#endif
